/**
 * Created by dukes on 2015/12/22.
 */
//module game{
    class TotalRechargeItemRender extends eui.ItemRenderer{
        public constructor(){
            super();
            this.skinName = "pet.TotalRechargeItemRenderSkin";
        }

        public img_ico:eui.Image;
        public prop_lab:eui.Label;
        public lab_name:eui.Label;
        public partAdded(name:string, instance:any) {
            super.partAdded(name, instance);
            if (name == "lab_name") {
                this.lab_name = instance;
            } else if (name == "prop_lab") {
                this.prop_lab = instance;
            } else if (name == "img_ico") {
                this.img_ico = instance;
            }
        }

        public dataChanged(){
            super.dataChanged();
            if( this.data.diamond){
                this.img_ico.source = GameConst.Res_Root+"resource/assets/items/diamond.png";
                this.prop_lab.text = this.lab_name.text = "钻石 x"+this.data.diamond;
            }else if( this.data.dogHair){
                this.img_ico.source = GameConst.Res_Root+"resource/assets/items/doghair.png";
                this.prop_lab.text = this.lab_name.text = "狗毛 x"+this.data.dogHair;
            }else if( this.data.catHair){
                this.img_ico.source = GameConst.Res_Root+"resource/assets/items/cathair.png";
                this.prop_lab.text = this.lab_name.text = "猫毛 x"+this.data.catHair;
            }else if( this.data.item){
                var goodInfo:GoodInfo = Model.GetGoodInfoById(this.data.item);
                if( goodInfo.type == Model.GOOD_TYPE_ITEM){
                    this.img_ico.source = GameConst.Res_Root+"resource/assets/items/"+this.data.item+ ".png";
                    this.lab_name.text = goodInfo.name+ " x "+this.data.count;
                }else if(goodInfo.type == Model.GOOD_TYPE_DECORATE){
                    var dec = Model.GetDecDateById(this.data.item);
                    this.img_ico.source = GameConst.Res_Root+"resource/assets/decorates/"+this.data.item+(goodInfo.classify != 4 ? ".png" :"-1.jpg");
                    this.lab_name.text = dec.name+ " x "+this.data.count;
                }
                if(goodInfo.term != 0){
                    var timeLast = goodInfo.term*60*1000;
                    if( timeLast > Model.DAY){
                        this.prop_lab.text = goodInfo.descs+"\n时效:"+Math.round(timeLast/Model.DAY)+"天";
                    }else{
                        this.prop_lab.text = goodInfo.descs+"\n时效:"+GetTimeStr(timeLast);
                    }
                }else{
                    this.prop_lab.text = goodInfo.descs+"\n时效:永久";
                }
            }
        }
    }
//}